<?php
require dirname(__FILE__) . '/checkuser.php';
require dirname(dirname(__FILE__)) . '/include/conf.php';
require dirname(dirname(__FILE__)) . '/include/database.php';

$wanfa_type = isset($_GET['wtype']) ? $_GET['wtype'] : 'jiaoqiupan';

$set_vals = conf_pair_sets('get', $wanfa_type);
if ($set_vals !== false){
	$profit_rate = $set_vals['profit_rate'];
	$money_188 = $set_vals['money_188'];
	$same_times = $set_vals['same_times'];
	$reminder = $set_vals['reminder'];
}else {
	// 未设置过配水参数或读取配置失败，使用如下默认值
	$profit_rate = 0;
	$money_188 = 1000;
	$same_times = 10;
	$reminder = 1;
}

$re = 'fail';
$msg = '没有新的';

$start_time = date('Y-m-d H:i:s', time() - 10 * 60);
$where = "where fetch_time>='{$start_time}' and status=0 and profit_rate>{$profit_rate}";
if ($wanfa_type == 'jiaoqiupan'){
	$where .= ' and wanfa in(1,2) ';
}else {
	$where .= ' and wanfa in(3,4) ';
}
$sql = "select id from match_paired {$where} limit 1";
$db = db_touzhu();
$re_db = $db->query($sql);
if (isset($re_db[0])){
	$re = 'succ';
	$msg = '有新的';
}

$result = array(
	're' => $re,
	'msg' => $msg
);
exit(json_encode($result));
